using UnityEngine;
using System.Collections;

public class NPCInfo : MonoBehaviour {
	
	public UISprite taskStatusSprite;
	
	int taskStatus;
	
	
	void Awake(){
		//ModelLocator.getInstance().addEventListener(ClientToClientFlag.CLIENT_TASK_ONE_STATUS,GetListenner);
	}
	
	private void GetListenner(object o,DispatchEventArgs e){
		taskStatus = (int)e.data[0];
		switch(taskStatus)
		{
		case GameDefine.NPCStatus_CanSubmit:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_COMPLETE;
			break;
		case GameDefine.NPCStatus_TaskAccept:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_CANACCESS;
			break;
		case GameDefine.NPCStatus_UnComplete:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_UNCOMPLETE;
			break;
		default:
			taskStatusSprite.enabled = false;
			break;
		}
		
		taskStatusSprite.MakePixelPerfect();
	}
	
	void Update(){
		taskStatus = TaskStatus.Instance().taskStatus;
		switch(taskStatus)
		{
		case GameDefine.NPCStatus_CanSubmit:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_COMPLETE;
			break;
		case GameDefine.NPCStatus_TaskAccept:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_CANACCESS;
			break;
		case GameDefine.NPCStatus_UnComplete:
			taskStatusSprite.enabled = true;
			taskStatusSprite.spriteName = GameDefine.TASKSTATUS_UNCOMPLETE;
			break;
		default:
			taskStatusSprite.enabled = false;
			break;
		}
		
		taskStatusSprite.MakePixelPerfect();
		
		//Vector3 direction = Camera.mainCamera.transform.position;
		//direction.z = - direction.z;
		//taskStatusSprite.transform.LookAt(direction);
	}
	
	
	void OnClick(){
		SceneClickLogic.getInstance().dispatchSceneObjClick(gameObject);
	}
}
